package script.learn.item
{
	import laya.events.Event;
	import laya.media.SoundManager;
	
	import model.lesson.SentenceVo;
	
	import ui.learn.SentenceItemUI;
	
	public class SentenceCell extends SentenceItemUI
	{
		private var sentenceVo:SentenceVo;
		public function SentenceCell()
		{
			super();
		}
		
		public function setData(data:SentenceVo):void
		{
			sentenceVo = data;
			
			this.engSentencetxt.text = sentenceVo.engSentence;
			this.chSentencetxt.text = sentenceVo.chSentence;
			
			this.commentstxt.text = sentenceVo.comments;
			
			this.engSpeaker.on(Event.CLICK,this,onSpeakEngSentence);
			this.chSpeaker.on(Event.CLICK,this,onSpeakChSentence);

			this.engSentencetxt.on(Event.CLICK,this,onSpeakEngSentence);
			this.chSentencetxt.on(Event.CLICK,this,onSpeakChSentence);

		}
		
		private function onSpeakEngSentence():void
		{
			SoundManager.playSound("sound/sentences/" + sentenceVo.engSoundRes);

		}
		
		private function onSpeakChSentence():void
		{
			SoundManager.playSound("sound/sentences/" + sentenceVo.chSoundRes);
			
		}
	}
}